﻿@model ApproveProcess

@{
    ViewBag.Title = "เพิ่มประเภทการอนุมัติ";
    var context = new GERPContext();
    int? appPrcGrpId = ViewBag.appPrcGrpId;
    var appPrcGrp = appPrcGrpId.HasValue ? context.ApproveProcessGroups.FirstOrDefault(o => o.AppPrcGrpId == appPrcGrpId) : null;
    var txtStyle = new {style="width:500px;"};
}

@using(Html.BeginForm())
{
    <h4 class="header">@ViewBag.Title &nbsp;&nbsp;&nbsp;&nbsp; 
        <a href="@Url.Action("Index")">ย้อนกลับ</a> |
        <input type="submit" value="บันทึก" />
    </h4>

    <div class="BlockContent">
        @Html.ValidationSummary()
        <h4 class="DetailHeader">@ViewBag.Title</h4>
        <div class="detail">
            <b>ชื่อประเภทการอนุมัติ</b> : @Html.TextBoxFor(m => m.Name, txtStyle)<br/>
            <b>อยู่ภายใต้ระบบอนุมัติ</b> : @Html.DropDownListFor(m=>m.AppPrcGrpId, 
                                                           from pg in context.ApproveProcessGroups.ToList() where pg.RecordStatus != "D" 
                                                           select new SelectListItem{Text=pg.AppPrcGrpId + " - " + pg.Name, Value = Convert.ToString(pg.AppPrcGrpId)
                                                               ,Selected = pg.AppPrcGrpId == appPrcGrpId})<br/>
            ใช้เป็นค่าเริ่มต้น: @Html.CheckBoxFor(m=>m.IsDefaultProcess)
        @{
            var context2 = new GERPContext(true);
            ApproveProcessMapping mapping = null;// context2.ApproveProcessMappings.FirstOrDefault(o => o.AppPrcId == Model.AppPrcId);
            TypeOfCompare selectedTypeOfCompare = TypeOfCompare.LessThan;
            decimal valueToCompare = 0;
            string mappingDescription = "";
            if(mapping != null)
            {
                selectedTypeOfCompare = mapping.TypeOfCompare;
                valueToCompare = mapping.ValueToCompare;
                mappingDescription = mapping.Description;
            }
        }
            <br/>
            เงื่อนไข: 
            <select id="conditionType" name="conditionType">
                <option value="@KPIS.GERP.Models.SYS.TypeOfCompare.LessThan" @(selectedTypeOfCompare == TypeOfCompare.LessThan ? "selected='selected'":"")>น้อยกว่า</option>
                <option value="@KPIS.GERP.Models.SYS.TypeOfCompare.MoreThan" @(selectedTypeOfCompare == TypeOfCompare.MoreThan ? "selected='selected'":"")>มากกว่า</option>
                <option value="@KPIS.GERP.Models.SYS.TypeOfCompare.Equal" @(selectedTypeOfCompare == TypeOfCompare.Equal ? "selected='selected'":"")>เท่ากับ</option>
                <option value="@KPIS.GERP.Models.SYS.TypeOfCompare.LessThanOrEqual"  @(selectedTypeOfCompare == TypeOfCompare.LessThanOrEqual ? "selected='selected'":"")>ไม่เกิน</option>
                <option value="@KPIS.GERP.Models.SYS.TypeOfCompare.MoreThanOrEqual" @(selectedTypeOfCompare == TypeOfCompare.MoreThanOrEqual ? "selected='selected'":"")>ตั้งแต่</option>
                <option value="@KPIS.GERP.Models.SYS.TypeOfCompare.NotEqual" @(selectedTypeOfCompare == TypeOfCompare.NotEqual ? "selected='selected'":"")>ไม่เท่ากับ</option> 
            </select> 
            <input type="text" id="mappingvalue" name="mappingvalue" value="@(valueToCompare)"/> 
            (หมายเหตุ: <input type="text" id="mappingDescription" name="mappingDescription" value="@(mappingDescription)"/>)
            <input type="radio" name="useMapping" value="use" @(mapping != null ? "checked" :"")/> ใช้งานเงื่อนไข
            <input type="radio" name="useMapping" value="not use" @(mapping == null ? "checked" :"")/> ไม่ต้องมีเงื่อนไข
            <br/>
            <b>รายละเอียด</b> : @Html.TextAreaFor(m => m.Description, txtStyle)
        </div>
    </div>
}